
class _RuleBean(object):

    def __init__(self):
        pass

    def get_data(self,request):

        ruleId = request.POST.get('hidden_target_Id')
        eURL = request.POST.get('eURL')
        sTable = request.POST.get('sTable')
        eScript = request.POST.get('eScript')
        tDayStart = request.POST.get('tDayStart')
        tDayEnd = request.POST.get('tDayEnd')
        lType = request.POST.get('lType')
        iValue = request.POST.get('iValue')
        remark = request.POST.get('remark')

        data = {}
        data['ruleId'] = ruleId
        data['eURL'] = eURL
        data['sTable'] = sTable
        data['eScript'] = eScript
        data['tDayStart'] = tDayStart
        data['tDayEnd'] = tDayEnd
        data['lType'] = lType
        data['iValue'] = iValue
        data['remark'] = remark

        return data

    def into_sql(self, min, max):
        print(min, max)
        job51_all = []
        topic = []
        con = self.sql_content.conten()
        sql_into = "select * from data_51job_she WHERE %d <= Data_Id and Data_Id<= %d" % (min, max)
        sql_topic = "select COLUMN_NAME from information_schema.COLUMNS where table_name ='data_51job_she'"
        cursor = con.cursor()
        try:
            cursor.execute(sql_into)
            rs = cursor.fetchall()
            for row in rs:
                list_row = list(row)
                list_row[6] = list_row[6][:150] + '....'
                list_row[7] = list_row[7][:150] + '....'
                # # print(list_row[3])
                job51_all.append(list_row)
            cursor.execute(sql_topic)
            rst = cursor.fetchall()
            for row in rst:
                list_row_t = list(row)
                topic.append(list_row_t)
        except Exception as e:
            print(e)
            con.rollback()
        cursor.close()
        con.close()
        print(topic)
        return job51_all, topic